/*
 * Author  : Pallab
 * Program : 442.cxx
 * 
 * 2011-11-25 02:14:01
 * I have not failed, I have just found 10000 ways that won't work.
 *
 */
#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <iomanip>

#include <ctime>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>
#include <cstdlib>

using namespace std;

#define VI vector< int >
#define CI( x ) scanf("%d",&x)
#define CL( x ) scanf("%lld",&x)
#define CD( x ) scanf("%lf",&x )
#define foR(i,st,ed) for(int i = st ; i < ed ; ++i )
#define fo(i,ed) foR( i , 0 , ed )
#define foE(i,st,ed) for(int i = st ; i <= ed ; ++i )
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define Int long long
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define mk make_pair
#define f first
#define s second
#define SET( ARRAY , VALUE ) memset( ARRAY , VALUE , sizeof(ARRAY) )

inline void wait(double seconds) {
	double endtime = clock()+(seconds * CLOCKS_PER_SEC);
	while (clock() < endtime) {
		;
	}
}
vector<int>bricks;
string line;
const int maxn = 500000;
int dp[ maxn+10 ];

inline int toI(string ss){
	int d;
	sscanf(ss.c_str(),"%d",&d);
return d;
}
inline void parse(){
	bricks.clear();
	stringstream ss(line);
	for(string tmp=""; getline(ss,tmp,','); ){
		int ln = LN(tmp);
		if( ln >=1 ){
			bricks.pb( toI(tmp) );
		}
	}
}

int nbricks;
int nsum;


inline void doit(){
	nbricks = SZ( bricks );
	nsum = 0;
	fo(i,nbricks){
		nsum+=bricks[i];
	}
	SET(dp,0);
	dp[0]=1;
	
	for(int i = 0; i<nbricks; ++i ){
		for(int current_sum=nsum; current_sum>=0; --current_sum ){
			if( dp[current_sum]!=0 ){
				#define F(X,Y)  (X,Y) > (Y) ? 0 : (X) 
				dp[ F(current_sum+bricks[i],nsum) ]+=1;
			}
		}
	}
	int mid = nsum/2;
	for(int i=mid;i>0;--i){
		if( dp[i] && (dp[i]%2) ==0 ){
			cout<<i<<"\n";
			return ;
		}
	}
	cout<<"-1\n";
}
inline void Read(){
// 	int itr=1;
// 	int lim=4;
	while( getline(cin,line) /*&& itr<=lim*/ ){
		parse();
		doit();
// 		++itr;
	}
}

int main() {
	Read();
	return 0;
} 
